Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix using drugs #37047

Merged
merged 1 commit into from
Jan 19, 2020
Merged

Fix using drugs #37047

merged 1 commit into from
Jan 19, 2020

Conversation

Trioct
Copy link
Contributor

@Trioct Trioct commented Jan 14, 2020

Summary

SUMMARY: None

Purpose of change

Fixes #37039 - Activating electronic cigarette doesn't give all the effects expected.

Describe the solution

This was happening because effects are split between consuming a drug and using the drug.
The drug is used when it is consumed, but if you just use a drug through the 'a' key, you don't get the effects from consuming.
If something has uses (can be used from the 'a' menu) when being used, it always falls through to its "use function", therefore not being consumed.
So I just made it consume medication even if it has a use, because I couldn't think of any comestible meds where there's a distinction between using it and consuming it. I made this late at night so let me know if I missed something.

Describe alternatives you've considered

Didn't come up with any satisfying alternatives.

Testing

Take varying drugs, using and eating/consuming should be the same. Using caffeinated chewing gum for example should give the stimulant effect instead of doing nothing.

@curstwist curstwist added <Bugfix> This is a fix for a bug (or closes open issue) Items / Item Actions / Item Qualities Items and how they work and interact labels Jan 14, 2020
@HoussemFerjaoui
Copy link
Contributor

HoussemFerjaoui commented Jan 15, 2020

the bug seems to be only related to ecig and caffeinated chew gum only, I cant seem to repro any problems with other drugs, hopefuly someone will confirm.

this fix might work since it will pass the medications to be handeled by consumed() function directly, but it will bypass all medications iuse_functions in general.
It is important to note that items that dosnt have a use_action should be consumed(if satisfies other conditions), and the ones that have a use_action should pass into the use action code section so it can be invoked.
on that note, items that have a use action(in this case the ecig and caffeinated gum) but dosnt achieve its purpose suggests that it has a problem related to its iuse function, therefore iuse::ecig() and iuse::chew() in iuse.cpp for this case.

@Trioct
Copy link
Contributor Author

Trioct commented Jan 15, 2020

Well it should work on any drug with a use action and effects outside the use action. For example cocaine gives you a high as part of the use action, but as part of the comestible it gives you stimulants. In my tests anyway, I found using coke did not give stimulants but consuming coke did.

Also as part of player::consume_med, it will invoke the item's use function if it has a use:

if( target.type->has_use() ) {
    amount_used = target.type->invoke( *this, target, pos() );
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) Items / Item Actions / Item Qualities Items and how they work and interact
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using electronic cigarette through "a" key won't satisfy nicotine addiction
4 participants